package com.lfec.dividiraconta;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Pessoa implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8039123859038746135L;
	
	private String nome;
	private List<Item> itemList = new ArrayList<Item>();
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public List<Item> getItemList() {
		return itemList;
	}
	public void setItemList(List<Item> itemList) {
		this.itemList = itemList;
	}
	
	public double getValor(){
		BigDecimal bd = new BigDecimal("0");
		for (Item item : itemList) {
			bd = bd.add(BigDecimal.valueOf(item.getValorPorPessoa()));
		}
		
		return bd.doubleValue();
	}
	public void addItem(Item item) {
		if (!itemList.contains(item)) {
			itemList.add(item);
		}
		
	}
	public void removeItem(Item item) {
		if (itemList.contains(item)) {
			itemList.remove(item);
		}
		
	}
	public double getValor10() {
		
		BigDecimal bd = BigDecimal.valueOf(getValor());
		
		return bd.multiply(new BigDecimal("1.1")).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
	}
	
	


}
